home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
171_01
/
m8087.mac
< prev
next >
Wrap
Text File
|
1983-11-21
|
29KB
|
818 lines
;***********************************************************************;
; ;
; M8087.MAC - File of macros which provide assembly level ;
; software support for use of 8087 NDP with ;
; the IBM personal computer ;
; ;
; Source: BYTE, August 1983, Vol. 8, No. 8, pp.331-374 ;
; ;
; Note - The initial 'if1' and final 'endif' have been removed ;
; from the original BYTE version. My Microsoft 'masm' ;
; balked at the construct hence I dropped it. ;
; Of course the same result is obtained by the statements ;
; ;
; if1 ;
; INCLUDE M8087.MAC ;
; endif ;
; ;
; in your Macro Assembler source, which seems to work. ;
; ;
; The following has not been tested by me, hence use at your own ;
; risk. I hope that this will help stimulate macro development ;
; for Microsoft C in the area of 8087 applications. ;
; ;
;***********************************************************************;
;***********************************************************************;
; ;
; ESC_REG - "REG" parameter specifies ESC value. Issue ;
; proper ESC sequence depending on REQ value. ;
; PARAM is a 6-bit parameter whose upper 3-bits ;
; make up the "xxx" bits in the ESC opcode (11011xxx) ;
; and lower 3-bits make up "yyy" bits in source ;
; byte following (using standard "mod" and "r/m" ;
; designators define byte as "modyyyr/m"). ;
; ;
;***********************************************************************;
ESC_REG macro PARAM,REG
;
; We need to determine what "reg" field assignment corresponds with
; the current value of REG. This is used as the source for the
; ESC operation. PARAM is used directly in the ESC call
;
ife REG ; Decrement until REG = 0, then issue ESC sequence
ESC PARAM,AX ; AX = 000b (see operand summary for 8088)
else
REG = REG - 1
ife REG
ESC PARAM,CX ; CX = 001b
else
REG = REG - 1
ife REG
ESC PARAM,DX ; DX = 010b
else
REG = REG - 1
ife REG
ESC PARAM,BX ; BX = 011b
else
REG = REG - 1
ife REG
ESC PARAM,SP ; SP = 100b
else
REG = REG - 1
ife REG
ESC PARAM,BP ; BP = 101b
else
REG = REG - 1
ife REG
ESC PARAM,SI ; SI = 110b
else ; If REG >= 7, assume 7
ESC PARAM,DI ; DI = 111b
endif
endif
endif
endif
endif
endif
endif
endm ; Done with ESC_REG macro
;***********************************************************************;
; ;
; CHECK_ST - Inputs parameter "ST(i)" and returns with REG=i ;
; ;
;***********************************************************************;
CHECK_ST macro P_ST
REG = -1 ; Assume no match is found
ifidn <&P_ST>,<ST(0)> ; Is i=0?
REG = 0
endif
ifidn <&P_ST>,<ST(1)>
REG = 1
endif
ifidn <&P_ST>,<ST(2)>
REG = 2
endif
ifidn <&P_ST>,<ST(3)>
REG = 3
endif
ifidn <&P_ST>,<ST(4)>
REG = 4
endif
ifidn <&P_ST>,<ST(5)>
REG = 5
endif
ifidn <&P_ST>,<ST(6)>
REG = 6
endif
ifidn <&P_ST>,<ST(7)>
REG = 7
endif
ifidn <&P_ST>,<st(0)> ; Is i=0?
REG = 0
endif
ifidn <&P_ST>,<st(1)>
REG = 1
endif
ifidn <&P_ST>,<st(2)>
REG = 2
endif
ifidn <&P_ST>,<st(3)>
REG = 3
endif
ifidn <&P_ST>,<st(4)>
REG = 4
endif
ifidn <&P_ST>,<st(5)>
REG = 5
endif
ifidn <&P_ST>,<st(6)>
REG = 6
endif
ifidn <&P_ST>,<st(7)>
REG = 7
endif
;
; If i not between 0 or 7, see if actually an
; "ST(i)" or "ST(I)" string, indicating use of
; top of stack element
;
ifidn <&P_ST>,<ST(i)>
REG = 0
endif
ifidn <&P_ST>,<ST(I)>
REG = 0
endif
ifidn <&P_ST>,<st(i)>
REG = 0
endif
ifidn <&P_ST>,<st(I)>
REG = 0
endif
endm
;***********************************************************************;
;* ;
;* CHK_CONC - Simple macro that will automatically insert ;
;* WAIT statements AFTER every 8087 instruction ;
;* which accesses CPU main memory. If variable ;
;* "AUTOSYNC" <> 0, then these WAITs will be ;
;* inserted (providing no concurrency but relieving;
;* the programmer from worrying about synchronizing;
;* data references. If the user program sets ;
;* AUTOSYNC to a zero value, then no WAITS ;
;* are inserted after the instructions and it is ;
;* the user's responsibility to insure synch- ;
;* ronization. ;
;* ;
;***********************************************************************;
CHK_CONC macro
if AUTOSYNC
WAIT ; Automatic syncronization
endif
endm
;***********************************************************************;
; ;
; CHOOSE_4 - Determine which of four parameters (XXX1 to XXX4) ;
; should be used in ESC sequence, depending on P1 ;
; and P2 values. P1 and P@ are parameters passed ;
; by user in macro call. XXX1 to XXX4 are macro- ;
; dependent parameters tacked on to the call to ;
; CHOOSE_4 by the specific 8087 macro called by the ;
; user code. ;
; ;
;***********************************************************************;